<?php

	include("common.php");
	
	$result = mysql_query("SELECT * FROM `197_albums` WHERE `album_id` = " . $_GET['album_id']);
	$album = mysql_fetch_assoc($result);
	
	$result = mysql_query("SELECT * FROM `197_images` WHERE `album_id` = " . $_GET['album_id']);
	$images = array();
	$image_block = array();
	$i = 0;
	while($row = mysql_fetch_assoc($result)){
		if($i == 4){
			$i = 0;
			array_push($images, $image_block);
			$image_block = array();
		}
		array_push($image_block, $row);
		$i++;
	}
	if($i != 0){
		array_push($images, $image_block);
	}
	
?>
<?php include("header.php"); ?>
<h1>相簿 - <?php echo $album['title']; ?></h1>
	<p style="text-align: center;"><?php if(!empty($images)){ ?><button class="prev custom">&laquo;</button><?php } ?><button class="custom" onclick="location.replace('albumList.php');">返回</button><?php if(!empty($images)){ ?><button class="next custom">&raquo;</button><?php } ?></p>
<?php if(empty($images)){ ?>
	<p>目前沒有相片。</p>
<?php } else { ?>
	<link rel="stylesheet" href="./jquery/css/apple-overlay.css" />
	<link rel="stylesheet" href="./jquery/css/scrollable.css" />
	<link rel="stylesheet" href="./jquery/css/scrollable-navigator.css" />
	<div class="navi" style="width: 100px; margin: 0 auto;"></div>
	<div class="apple scrollable">
		<div class="items">
			<?php foreach($images as $image_block){ ?>
				<div>
					<?php foreach($image_block as $row){ ?>
						<img src="./imageResize.php?width=225&filename=files/<?php echo $album['dir_name']; ?>/<?php echo $row['filename']; ?>" rel="#image-<?php echo $row['image_id']; ?>" />
					<?php } ?>
				</div>
			<?php } ?>
		</div>
	</div>
	<p style="text-align: center;"><button class="prev custom">&laquo;</button><button class="custom" onclick="location.replace('albumList.php');">返回</button><button class="next custom">&raquo;</button></p>
	<?php foreach($images as $image_block){ ?>
		<?php foreach($image_block as $row){ ?>
			<div class="apple_overlay" id="image-<?php echo $row['image_id']; ?>">
				<a href="./files/<?php echo $album['dir_name']; ?>/<?php echo $row['filename']; ?>" target="_blank"><img style="border: 0;" src="./imageResize.php?height=400&filename=files/<?php echo $album['dir_name']; ?>/<?php echo $row['filename']; ?>" /></a>
				<div class="details">
					<p id="description-<?php echo $row['image_id']; ?>">
						<?php print(!empty($row['title']) ? $row['title'] : "本相片沒有描述。"); ?><br /><br />
					</p>
				</div>
			</div>
		<?php } ?>
	<?php } ?>
	<script type="text/javascript">
			$(".apple img[rel]").overlay({effect: 'apple'});
			$(".scrollable").scrollable().navigator();
	</script>

<?php } ?>
<?php include("sidebar.php"); ?>
<?php include("footer.php"); ?>